
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('user-agent='+UserAgent().random)  # 修改请求头，伪装浏览器型号
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])  # 设置开发模式，避免被检测
# driver = webdriver.Chrome(chrome_options=chrome_options) # 已经设置PATH环境变量
# 未在PATH环境变量中设置，需要设置驱动可执行路径
driver = webdriver.Chrome(executable_path='D:\\webdriver\\chromedriver.exe', chrome_options=chrome_options)
driver.maximize_window()  # 最大化
driver.get("url")

with open("douyin.js", "r", encoding="gbk") as f:
    line = f.read()
d=driver.execute_script(line)